package com.cowcowit.springcloud.service.impl;

import com.cowcowit.springcloud.service.IMessageProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.function.StreamBridge;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class MessageProviderImpl implements IMessageProvider {

    // 消息发送管道
    @Autowired
    private StreamBridge streamBridge;

    @Override
    public String send() {
        String serial = UUID.randomUUID().toString();
        // 使用 streamBridge 发送消息到指定的 binding
        streamBridge.send("output", serial);
        System.out.println("*****serial: " + serial);
        return null;
    }
}
